//导入express
const express = require('express')
const app = express()
//导入cors
const cors=require('cors')
const bodyParser=require('body-parser')

//封装的res.cc()
app.use(function(req,res,next){
    res.cc=function (err,status=403){
        res.send({
            status,message:err instanceof Error ? err.message:err
        })
    }
    next()
})

app.use(cors())
app.use(bodyParser.json())
//下面中间件只能解析www格式表单数据
app.use(bodyParser.urlencoded({extended:true}))




const setRouter=require('./router/set')
const baseRouter = require('./router/base')
app.use('/api/set',setRouter)
app.use('/api/base',baseRouter)



//启动服务器
app.listen(3000,function(){
    console.log("端口开放3000ai");
})